package com.yangj.util;

import com.yangj.entity.*;
import net.sf.json.*;
import com.yangj.service.*;

public class CreateMenu
{
    public static void main(final String[] args) {
    		Button btn = new Button();	
    		//第一个一级菜单
    		btn.getButton().add( new ClickButton("菜单一","1"));
    		//第二个一级菜单
    		btn.getButton().add( new ViewButton("菜单二","https://gityang2016.gitee.io/"));
    		//第三个一级菜单
    		SubButton subButton = new SubButton("有子菜单");
    		//为第三菜单增加3个子菜单
    		subButton.getSub_button().add(new PhotoOrAlbum("传图", "31"));
    		subButton.getSub_button().add(new ClickButton("点击","32"));
    		subButton.getSub_button().add(new ViewButton("哔哩哔哩","https://www.bilibili.com/"));

    		btn.getButton().add(subButton);
    		JSONObject jsonObject = JSONObject.fromObject(btn);
    		StringBuilder stringBuilder = new StringBuilder();
    		System.out.println(jsonObject.toString());
    		
    		//准备url
    		String url = WeChatVerifyService.getMenuUrl();
    		url = url.replace("ACCESS_TOKEN", WeChatVerifyService.getAccessToken());
    		//发送请求
    		String result = MyUtils.post(url, jsonObject.toString());
    		System.out.println(result);
    	}
}
